package com.lyn.io.file

import java.util.concurrent.ConcurrentHashMap

/**
 * 文件夹工厂
 * @author longyn 2025/03/01
 * @version 1.0.0
 */
object FolderFactory {

    private val folderMap: MutableMap<String, Folder> = ConcurrentHashMap()

    fun create(name: String = "defaultFolder", path: String, isCreate: Boolean = true): Folder {
        if (folderMap.containsKey(name)) {
            return folderMap[name]!!
        }
        val folderImp = FolderImp()
        folderImp.initialize(path, name, isCreate)
        folderMap[name] = folderImp
        return folderImp
    }

    fun get(name: String = "defaultFolder"): Folder? {
        return folderMap[name]
    }
}